#include "question.h"
#include <QJsonObject>

Question::Question(QObject *parent)
    : QObject{parent}
{}




void Question::parseCommonData(const QJsonObject &json)
{
    m_id = json.value("id").toInt();
    m_stem = json.value("content").toString();
}



void Question::setUserAnswer(const QString &answer)
{
    if (m_userAnswer != answer) {
        m_userAnswer = answer;
        emit answerChanged(); // 通知答案变更
    }
}



QJsonObject Question::toJson() const
{
    //问题出在 基类这了
    QJsonObject obj;
    obj.insert("id", m_id);
    obj.insert("content", m_stem);
    obj.insert("typeCaption", m_typeString);
    obj.insert("studentAnswer", m_userAnswer);
    return obj;

}

